package com.jzo2o.customer.controller.consumer;

import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description AccountController
 * @Author dmx
 * @Date 2024-12-02
 */
@RestController("accountController")
@RequestMapping
@Api(tags = "机构端和服务端账户接口")
public class AccountController {

    @Autowired
    private AccountService accountService;

    /**
     * 新增用户银行账户
     * @param dto
     */
    @PostMapping("worker/bank-account")
    @ApiOperation("新增用户银行账户")
    public void workerBankAccount(@RequestBody BankAccountUpsertReqDTO dto){
        accountService.addWorkerBankAccount(dto);
    }

    /**
     * 获取当前用户的银行账号
     * @return
     */
    @GetMapping("/worker/bank-account/currentUserBankAccount")
    @ApiOperation("获取当前用户的银行账号接口")
    public BankAccountResDTO getAccount(){
        return accountService.getAccountByServeProviderId();
    }


    /**
     * 机构端--新增或更新银行账户信息
     */
    @PostMapping("/agency/bank-account")
    @ApiOperation("机构端--新增或更新银行账户信息接口")
    public BankAccountResDTO saveAgencyBankAccount(@RequestBody BankAccountUpsertReqDTO dto){
        return accountService.saveAgencyBankAccount(dto);
    }


    @GetMapping("/agency/bank-account/currentUserBankAccount")
    @ApiOperation("获取当前机构的银行账号接口")
    public BankAccountResDTO getAgencyAccount(){
        return accountService.getAccountByServeProviderId();
    }

}
